/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wisimconsole;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LinearGradientPaint;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.geom.Point2D;
import javax.swing.JSlider;
import javax.swing.plaf.basic.BasicSliderUI;

/**
 *
 * @author brother
 */
public class MySliderUI2 extends BasicSliderUI {
    
    private static float[] fracs = {0.0f, 0.2f, 0.4f, 0.6f, 0.8f, 1.0f};
    private LinearGradientPaint p;
    Color[] colors = {Color.magenta, Color.blue, Color.cyan, Color.green, Color.yellow, Color.red};

    public MySliderUI2(JSlider slider) {
	super(slider);
	
	
	
    }

    @Override
    public void paintTrack(Graphics g) {
	Graphics2D g2d = (Graphics2D) g;
	Rectangle t = trackRect;
	Point2D start = new Point2D.Float(t.x, t.y);
	Point2D end = new Point2D.Float(t.width, t.height);
	p = new LinearGradientPaint(start, end, fracs, colors);
	g2d.setPaint(p);
	g2d.fillRect(t.x, t.y, t.width, t.height / 4);
	
    }
    static final String start="t1";
    @Override
    public void paintThumb(Graphics g) {
	Graphics2D g2d = (Graphics2D) g;
	g2d.setRenderingHint(
		RenderingHints.KEY_ANTIALIASING,
		RenderingHints.VALUE_ANTIALIAS_ON);
	
	Rectangle t = thumbRect;
	t.width=25;
	t.height=25;
	t.y=0;
	g2d.setColor(Color.PINK);
//	int[] xs={t.x,t.x + t.width - 1,t.x + tw2},ys={t.y,t.y,t.y + t.height / 2};
	int[]	xs = {t.x,	    t.x+t.width/2,  t.x+t.width/2}, 
		ys = {t.y + t.height / 4,   t.y,  t.y+t.height/2};
	g2d.fillPolygon(xs, ys, 3);
	g2d.setColor(Color.BLUE);
	g2d.drawString(start, t.x+2, t.y + t.height-2);
//	g2d.drawLine(t.x, t.y, t.x + t.width - 1, t.y);
//	g2d.drawLine(t.x, t.y, t.x + tw2, t.y + t.height / 2);
//	g2d.drawLine(t.x + t.width - 1, t.y, t.x + tw2, t.y + t.height / 2);
    }
    public int getXThumb(){
	return thumbRect.x;
    }
    public int getYThumb(){
	return thumbRect.y;
    }
    public void setXThumb(int x){
	thumbRect.x=x;
    }
}
